Skip to content

Conversation

@daum3ns
Copy link

@daum3ns daum3ns commented Oct 24, 2025

This change enables the file-based (standalone) provider to understand and load custom resources that are defined by an extension server.

  • the LoadResourcesFromYAMLBytes now accepts a server config pointer. When a resource kind is unknown, the loader checks the configured ExtensionManager and, if the GVK matches a declared policy resource, stores the object as an ExtensionServerPolicy
    • Updated callers to pass the new parameter
  • the newOfflineGatewayAPIClient function now accepts extensionServerPoliciesGVKs, which are then registered in the scheme. this allows the offline reconciler to manipulate custom resources
  • added testcases for decoder, offline_controller and config_loader,
    • the config reload test starts Envoy Gateway in standalone mode, hot-reloads a configuration that adds an ExtensionManager with policy resources, and verifies the new GVKs are recognized

Fixes #7141

Release Notes: Yes/No

Notes:
I found out that we most probably have the same problem with ExtensionManagers backendResources and resources field (at least the config_loader test can easily be extended to show that the registration in the scheme is missing).

I think it could be fixed in a similar way (although not sure whether the translator needs to be adapted as well). See the commented code snippets...

However, I'm very new to envoy-gateway so I'm still raising this PR to get a first, much appreciated feedback whether it makes sense to continue in this direction..

@daum3ns daum3ns requested a review from a team as a code owner October 24, 2025 14:23
@arkodg arkodg requested a review from shawnh2 October 24, 2025 14:25
@arkodg arkodg added this to the v1.6.0 Milestone milestone Oct 24, 2025
@daum3ns daum3ns force-pushed the support-custom-CRDs-for-ExtensionServer-in-Standalone-Mode branch from 1f7a84b to d66478e Compare October 24, 2025 14:29
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 89.41176% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.41%. Comparing base (e781fbd) to head (676c888).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/provider/file/store.go 25.00% 4 Missing and 2 partials ⚠️
internal/gatewayapi/runner/runner.go 0.00% 2 Missing ⚠️
internal/provider/file/file.go 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7331      +/-   ##
==========================================
+ Coverage   72.26%   72.41%   +0.14%     
==========================================
  Files         231      231              
  Lines       34071    34128      +57     
==========================================
+ Hits        24622    24714      +92     
+ Misses       7674     7646      -28     
+ Partials     1775     1768       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@daum3ns
Copy link
Author

daum3ns commented Oct 30, 2025

@shawnh2 i have added a test scenario which shows we have the same problem for the other 2 resources fields in the extension manager in standalone mode....
f996f5a

i think i will address this in this PR as well.. (or would you prefer a separate Issue/PR ?)
Can you answer this question here?
https://github.com/daum3ns/envoy-gateway/blob/support-custom-CRDs-for-ExtensionServer-in-Standalone-Mode/internal/gatewayapi/resource/load.go#L454
Im not sure whether all extensions should go in the same field or wether there are dedicated fields for the different types...

@daum3ns
Copy link
Author

daum3ns commented Nov 4, 2025

I figured it out, extensionRefFilter is the correct place to put it, also had to persist it ..
see ed62242 and 63e49df

shawnh2
shawnh2 previously approved these changes Nov 6, 2025
Copy link
Contributor

@shawnh2 shawnh2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@shawnh2 shawnh2 requested review from a team November 6, 2025 00:56
Spec: typedSpec.(gwapiv1b1.ReferenceGrantSpec),
}
resources.ReferenceGrants = append(resources.ReferenceGrants, referenceGrant)
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we improve this logic and avoid labels

one recommendation is to setup a gvkMap in the beginning of the func, populate it based off EnvoyGateway and use it here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is a good idea!

extGKs = append(extGKs, schema.GroupKind{Group: gvk.Group, Kind: gvk.Kind})
}
// Include policy resources so extension-defined custom policies are recognised.
for _, gvk := range r.EnvoyGateway.ExtensionManager.PolicyResources {
Copy link
Contributor

@arkodg arkodg Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a bug fix @guydc

@daum3ns
Copy link
Author

daum3ns commented Nov 6, 2025

i think i found yet another problem in standalone mode :D
when comparing the WithIndex calls in the creation of the controller_offline.go to internal/provider/kubernetes/indexers.go it looks like these indices are missing:

clusterTrustBundleBackendIndex
clusterTrustBundleBtlsIndex
clusterTrustBundleCtpIndex
secretBackendIndex
configMapBackendIndex

is this intentional or just got forgotten?
i will try to write a test for this...

@daum3ns
Copy link
Author

daum3ns commented Nov 7, 2025

the test shows the problem ...
the first assertion is okay but the second fails:

Error:      	Received unexpected error:
       List on GroupVersionKind gateway.envoyproxy.io/v1alpha1, Kind=Backend specifies selector on field secretBackendIndex, but no index with name secretBackendIndex has been registered for GroupVersionKind gateway.envoyproxy.io/v1alpha1, Kind=Backend
Test:       	TestNewOfflineGatewayAPIControllerIndexRegistration/offline_controller_creation_list_index_test

when I register the tested index in the offline_controller, it succeeds...

return fake.NewClientBuilder().
		WithScheme(scheme).
[...]
WithIndex(&egv1a1.Backend{}, secretBackendIndex, secretBackendIndexFunc).
[...]

@shawnh2
Copy link
Contributor

shawnh2 commented Nov 8, 2025

good catch @daum3ns , those missing indexes were introduced by #6353,feel free to make offline controller indexer complete.

un.SetNamespace(namespace)
switch category {
case extFilter, extBackend:
resources.ExtensionRefFilters = append(resources.ExtensionRefFilters, *un)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this logic right of adding the ext backend into ext ref flters ?
cc @Xunzhuo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think so, the controller does it the same way
#7331 (comment)

@arkodg arkodg modified the milestones: v1.6.0 Milestone, Backlog Nov 9, 2025
@daum3ns
Copy link
Author

daum3ns commented Nov 11, 2025

good catch @daum3ns , those missing indexes were introduced by #6353,feel free to make offline controller indexer complete.

i have added all missing indices, however the test could be improved...

@daum3ns
Copy link
Author

daum3ns commented Nov 11, 2025

strange.. the failing conformance test succeeds locally on my machine...

@daum3ns daum3ns force-pushed the support-custom-CRDs-for-ExtensionServer-in-Standalone-Mode branch from 6b145ed to 19fe896 Compare November 11, 2025 12:35
@zhaohuabing zhaohuabing force-pushed the support-custom-CRDs-for-ExtensionServer-in-Standalone-Mode branch from 3825255 to 7c44f70 Compare November 11, 2025 12:52
…nt scheme

Teach the offline controller to recognise custom extension-server
policy GVKs supplied by an extension so they can be decoded and later
processed by the translator.

- newOfflineGatewayAPIClient now accepts extServerPoliciesGVKs
- each GVK is registered as Unstructured/UnstructuredList in the
  fake client's scheme
- call-site updated to pass the collected policy GVKs

Signed-off-by: daum3ns <[email protected]>
Add policy resources from ExtensionManager to extGKs so custom
extension policies are recognised during translation.

Signed-off-by: daum3ns <[email protected]>
…f an EnvoyGateway configuration containing a standalone extension server.

Signed-off-by: daum3ns <[email protected]>
yaml and it gets the default namespace

Signed-off-by: daum3ns <[email protected]>
can check custom resource definitions

Signed-off-by: daum3ns <[email protected]>
Signed-off-by: daum3ns <[email protected]>
ExtensionManager.resources and ExtensionManager.backendResources, use
assertions

Signed-off-by: daum3ns <[email protected]>
Signed-off-by: daum3ns <[email protected]>
extensionmanager.backendResources

Signed-off-by: daum3ns <[email protected]>
instead of srv.EnvoyGateway (replace function parameter, adapt callers
and tests)

Signed-off-by: daum3ns <[email protected]>
Signed-off-by: daum3ns <[email protected]>
and to avoid the loop over every resource in extensionanager.

Signed-off-by: daum3ns <[email protected]>
@zhaohuabing zhaohuabing force-pushed the support-custom-CRDs-for-ExtensionServer-in-Standalone-Mode branch from 7c44f70 to b426305 Compare November 11, 2025 15:48
@daum3ns
Copy link
Author

daum3ns commented Nov 12, 2025

i cant resolve this locally.. the test succeeds....

screenshots_11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom CRDs for ExtensionServer in Standalone Mode

3 participants